<?php

function deal()
{
	$hand1 = "";
	$hand2 = "";
	$hand3 = "";
	$hand4 = "";
	
	$deck = array("1s","2s","3s","4s","5s","6s","7s","8s","9s","0s","Js","Qs","Ks",
				  "1h","2h","3h","4h","5h","6h","7h","8h","9h","0h","Jh","Qh","Kh",
				  "1c","2c","3c","4c","5c","6c","7c","8c","9c","0c","Jc","Qc","Kc",
				  "1d","2d","3d","4d","5d","6d","7d","8d","9d","0d","Jd","Qd","Kd");

	shuffle($deck);

	for ($i=0; $i<52; $i++)
	{
		if ($i < 13)
		{
			if($deck[$i] == "3d") { $turn = 1; }
			$hand1 .= $deck[$i];
		}
		else if ($i >= 13 && $i < 26)
		{
			if($deck[$i] == "3d") { $turn = 2; }
			$hand2 .= $deck[$i];
		}
		else if ($i >= 26 && $i < 39)
		{
			if($deck[$i] == "3d") { $turn = 3; }
			$hand3 .= $deck[$i];
		}
		else if ($i >= 39 && $i < 52)
		{
			if($deck[$i] == "3d") { $turn = 4; }
			$hand4 .= $deck[$i];
		}
		else
		{
			print "Card Count Error";
		}
	}

	$xml = "";
	$xml .= "<turn>".$turn."</turn>";
	$xml .= "<type>0</type>";
	$xml .= "<hand1>".$hand1."</hand1>";
	$xml .= "<status1>READY</status1>";
	$xml .= "<hand2>".$hand2."</hand2>";
	$xml .= "<status2>READY</status2>";
	$xml .= "<hand3>".$hand3."</hand3>";
	$xml .= "<status3>READY</status3>";
	$xml .= "<hand4>".$hand4."</hand4>";
	$xml .= "<status4>READY</status4>";
	$xml .= "<table></table>";

	return $xml;
}

?>